package verify

import (
	"awesomeProject/app/request"
	"errors"
	"fmt"
)

func ShipmentPagination(r *request.ShipmentPagination) error {
	if r.PageIndex == 0 {
		r.PageIndex = 1
	}
	if r.PageSize == 0 {
		r.PageSize = 20
	}
	return nil
}

func ShipmentDetailView(r *request.ShipmentDetailView) error {
	if r.ShopId <= 0 {
		return errors.New(fmt.Sprintf("店铺ID错误！"))
	}

	if r.ShipmentId == "" {
		return errors.New(fmt.Sprintf("请填写货件编号！"))
	}
	return nil
}

func ShipmentTrackBoxView(r *request.ShipmentTrackBoxView) error {
	if r.ShopId <= 0 {
		return errors.New(fmt.Sprintf("店铺ID错误！"))
	}
	if r.ShipmentId == "" {
		return errors.New(fmt.Sprintf("请填写货件编号！"))
	}
	return nil
}

func ShipmentBoxView(r *request.ShipmentBoxView) error {
	if r.ShopId <= 0 {
		return errors.New(fmt.Sprintf("店铺ID错误！"))
	}
	if r.ShipmentId == "" {
		return errors.New(fmt.Sprintf("请填写货件编号！"))
	}
	return nil
}

func ShipmentReceivedDetailView(r *request.ShipmentReceivedDetailView) error {
	if r.ShopId <= 0 {
		return errors.New(fmt.Sprintf("店铺ID错误！"))
	}
	if r.ShipmentId == "" {
		return errors.New(fmt.Sprintf("请填写货件编号！"))
	}
	if r.TabFilter == "" {
		r.TabFilter = "all"
	}
	return nil
}
